package com.claire.jing.utils;

import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;

import java.util.List;

public class ErrorMessUtil {
    public static String getErrorMess(BindingResult result)
    {
        List<ObjectError> allErrors = result.getAllErrors();
        StringBuffer buffer = new StringBuffer();
        if (allErrors.size()>0){
            for (ObjectError allError : allErrors) {
                buffer.append(allError.getDefaultMessage());
            }
            return buffer.toString();
        }

        return null;
    }
}
